//
//  MainViewController.m
//  LoveDraw
//
//  Created by 零零壹 on 2017/7/8.
//  Copyright © 2017年 梁晨. All rights reserved.
//

#import "MainViewController.h"
#import <SDCycleScrollView.h>

#import "MainTableViewCell.h"
#import "TeacherTimeTableViewCell.h"

#import "TimeTableModel.h"

#import "TimetableViewController.h"

#import "MainTeacherModel.h"

#import "KeBiaoTableViewCell.h"

#import "KeBiaoSecTableViewCell.h"

#import "SelectClassV.h"

#import "SelectTeacherModel.h"

#import "KeBiaoListViewController.h"

#import "MainWebViewController.h"

#import "TeaacherCheckHolidayViewController.h"

#import "MainCatergyV.h"

#import "GYChangeTextView.h"

#import "ChildViewController.h"

#import "LessonViewController.h" // 课程管理

#import "RecordViewController.h"

#import "LessonShareViewController.h"

#import "AdvDetailViewController.h"

#import "AdvDetailViewController.h"


#import "MyClassViewController.h"
#import "LessonTeacherViewController.h"
#import "TeacherHoildayViewController.h"
#import "TeacherFeedBackViewController.h"
#import "MineShouRuViewController.h"
#import "MessageViewController.h"


@interface MainViewController ()<UITableViewDelegate,UITableViewDataSource,SDCycleScrollViewDelegate,GYChangeTextViewDelegate,MainCatergyVDelegate>

/**
 轮播图
 */
@property(nonatomic,strong)SDCycleScrollView *cycleScrollView;

/**
 列表页
 */
@property(nonatomic,strong)UITableView *listV;

/**
 轮播数组
 */
@property(nonatomic,strong)NSMutableArray *cycleArr;

/**
 列表数组
 */
@property(nonatomic,strong)NSMutableArray *listArr;


/**
 列表头部视图
 */
@property(nonatomic,strong)UIView *tabHeadV;


/**
 抽屉打开的按钮
 */
@property(nonatomic,strong)UIButton *drawerLeftBtn;


/**
 日历按钮
 */
@property(nonatomic,strong)UIButton *more_timetable;

@property(nonatomic,strong)NSString *isTeacher;

@property(nonatomic,strong)NSMutableArray *TeacherList;

@property(nonatomic,strong)SelectClassV *ClassAlertV;

@property(nonatomic,strong)MainCatergyV *CatergyV;

@property(nonatomic,strong)UIView *GongGaoV;

@property(nonatomic,strong)GYChangeTextView *notes;

@property(nonatomic,strong)NSMutableArray *gongGaoArr;

@property(nonatomic,strong)UIButton *MessageBtn;
@property(nonatomic,strong)UILabel *NumL;

@end

@implementation MainViewController

-(UIView *)GongGaoV
{
    if (!_GongGaoV)
    {
        _GongGaoV = [[UIView alloc]initWithFrame:CGRectMake(0, KscreenW*3/5+KscreenW/5+25+5, KscreenW, 30)];
        _GongGaoV.backgroundColor = [UIColor whiteColor];
    }
    return _GongGaoV;
}

-(MainCatergyV *)CatergyV
{
    if (!_CatergyV) {
        _CatergyV = [[MainCatergyV alloc]initWithFrame:CGRectMake(0, KscreenW*6/10, KscreenW, KscreenW/5+25)];
        _CatergyV.Delegate = self;
    }
    return _CatergyV;
}

-(SelectClassV *)ClassAlertV
{
    if (!_ClassAlertV) {
        _ClassAlertV = [[SelectClassV alloc]initWithFrame:CGRectMake(0, 0, KscreenW, KscreenH)];

        _ClassAlertV.alpha = 0;
    }
    return _ClassAlertV;
}

/**
 懒加载轮播图
 
 @return 幻灯图
 */
-(SDCycleScrollView *)cycleScrollView
{
    if (!_cycleScrollView) {
        _cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, kScreenWidth, KscreenW*6/10) imageURLStringsGroup:nil];
        _cycleScrollView.backgroundColor = [UIColor whiteColor];
    }
    return _cycleScrollView;
}


/**
 列表
 @return 列表页面
 */
-(UITableView *)listV
{
    if (!_listV) {
        _listV = [[UITableView alloc]initWithFrame:CGRectMake(0, -20, KscreenW, KscreenH+20) style:(UITableViewStylePlain)];
        _listV.backgroundColor =[UIColor whiteColor];
        _listV.delegate = self;
        _listV.dataSource = self;
        _listV.estimatedSectionHeaderHeight = 0;
        _listV.estimatedSectionFooterHeight = 0;
        [_listV registerClass:[MainTableViewCell class] forCellReuseIdentifier:@"MainTableViewCell"];
        [_listV registerNib:[UINib nibWithNibName:@"KeBiaoTableViewCell" bundle:nil] forCellReuseIdentifier:@"KeBiaoTableViewCell"];
        [_listV registerNib:[UINib nibWithNibName:@"KeBiaoSecTableViewCell" bundle:nil] forCellReuseIdentifier:@"KeBiaoSecTableViewCell"];
        _listV.separatorStyle = 0;
    }
    return _listV;
}

/**
 懒加载列表数据

 @return 列表数据
 */
-(NSMutableArray *)listArr
{
    if (!_listArr) {
        _listArr = [NSMutableArray array];
    }
    return _listArr;
}


/**
 老师数据列表

 @return
 */
-(NSMutableArray *)TeacherList
{
    if (!_TeacherList) {
        _TeacherList = [NSMutableArray array];
    }
    return _TeacherList;
}

/**
 懒加载轮播图数据

 @return 轮播图数据
 */
-(NSMutableArray *)cycleArr
{
    if (!_cycleArr) {
        _cycleArr = [NSMutableArray array];
    }
    return _cycleArr;
}


/**
 顶部列表

 @return <#return value description#>
 */
-(UIView *)tabHeadV
{
    if (!_tabHeadV) {
        _tabHeadV = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KscreenW, KscreenW*6/10+KscreenW/5+25+30+10+30)];
        _tabHeadV.backgroundColor = UIColors(0xF8F9FA);
    }
    return _tabHeadV;
}


/**
 日历按钮

 @return <#return value description#>
 */
-(UIButton *)more_timetable
{
    if (!_more_timetable) {
        _more_timetable = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _more_timetable.frame = CGRectMake(KscreenW-100, KscreenW*6/10-30, 60, 60);
        [_more_timetable setImage:[UIImage imageNamed:@"more_timetable"] forState:UIControlStateNormal];
        [_more_timetable addTarget:self action:@selector(timetableOnclick) forControlEvents:UIControlEventTouchUpInside];
    }
    return _more_timetable;
}

-(UIButton *)drawerLeftBtn
{
    if (!_drawerLeftBtn) {
        _drawerLeftBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _drawerLeftBtn.frame = CGRectMake(15, 20, 40, 40);
        [_drawerLeftBtn setImage:[UIImage imageNamed:@"left_more"] forState:(UIControlStateNormal)];
        [_drawerLeftBtn addTarget:self action:@selector(showLeftAct) forControlEvents:(UIControlEventTouchUpInside)];

    }
    return _drawerLeftBtn;
}

-(UILabel *)NumL
{
    if (!_NumL) {
        _NumL = [[UILabel alloc]initWithFrame:CGRectMake(KscreenW-15-20, 17, 20, 20)];
        _NumL.textColor = [UIColor whiteColor];
        _NumL.backgroundColor = [UIColor redColor];
        _NumL.font = [UIFont systemFontOfSize:14];
        _NumL.layer.cornerRadius = 10;
        _NumL.layer.masksToBounds = YES;
        _NumL.textAlignment = 1;
    }
    return _NumL;
}

-(UIButton *)MessageBtn
{
    if (!_MessageBtn)
    {
        _MessageBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _MessageBtn.frame = CGRectMake(KscreenW-15-45, 20, 35, 35);
        [_MessageBtn setImage:[UIImage imageNamed:@"mesg"] forState:(UIControlStateNormal)];
        [_MessageBtn addTarget:self action:@selector(MessageAct) forControlEvents:(UIControlEventTouchUpInside)];
    }
    return _MessageBtn;
}


-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self getNumber];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    

    // type是二的时候 既是老师 也是家长
    if([[[NSUserDefaults standardUserDefaults] objectForKey:Ktype] isEqualToString:@"2"])
    {
        self.isTeacher = @"1"; // 是老师界面
    }else
    {
        self.isTeacher = @"2"; // 完全不是老师
    }

    [self.view addSubview:self.listV];
    self.listV.tableHeaderView = self.tabHeadV;

    [self cycRequest];

    [self gonggaoRequest];

//    [self.tabHeadV addSubview:self.notes];

    if ([self.isTeacher isEqualToString:@"1"])
    {
        [self TeacherRequest];
    }else
    {
        [self listRequest];
    }

    [self.view addSubview:self.ClassAlertV];
}

-(void)gonggaoRequest
{
    [RequestManager RequstWithUrl:@"/index.php?g=App&m=Index&a=noticeList" parmDic:@{@"pagesize":@"3"} requestType:RequestGET Success:^(id data)
    {
        self.gongGaoArr = data;

        self.notes = [[GYChangeTextView alloc]initWithFrame:CGRectMake(92, 0, KscreenW-92-10, 30)];
        [self.GongGaoV addSubview:self.notes];
        self.notes.delegate = self;
        NSMutableArray *titArr = [NSMutableArray array];
        for (NSDictionary *dataDic in self.gongGaoArr)
        {
            [titArr addObject:dataDic[@"title"]];
        }

        if (titArr.count == 0)
        {

        }else
        {

            [self.notes animationWithTexts:titArr];
        }

    } error:^(NSError *error) {

    }];
}

- (void)gyChangeTextView:(GYChangeTextView *)textView didTapedAtIndex:(NSInteger)index
{
    if ( self.gongGaoArr.count == 0)
    {
    }else
    {
        NSDictionary *dataDic = self.gongGaoArr[index];
        AdvDetailViewController *VC = [[AdvDetailViewController alloc]init];
        [self.navigationController pushViewController:VC animated:YES];
        VC.aid = dataDic[@"aid"];
    }
}

#pragma mark ---tableV的代理方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if ([self.isTeacher isEqualToString:@"1"])
    {
        NSArray *dataArr = self.TeacherList[section][@"data_v"];
        NSLog(@"第%ld分区有%ld个cell",section,dataArr.count);
        return dataArr.count;
    }else
    {
        return self.listArr.count;
    }
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    if ([self.isTeacher isEqualToString:@"1"])
    {
        return self.TeacherList.count;
    }else
    {
        return 1;
    }
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([self.isTeacher isEqualToString:@"1"])
    {
        NSDictionary *sectionDic = self.TeacherList[indexPath.section];
        NSArray *dataArr = sectionDic[@"data_v"];
        NSDictionary *rowDic = dataArr[indexPath.row];
        if (indexPath.row == 0)
        {
            KeBiaoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"KeBiaoTableViewCell" forIndexPath:indexPath];
            cell.yearL.text = sectionDic[@"date_year"];
            cell.dateL.text = sectionDic[@"date_md"];
            cell.titleL.text = rowDic[@"detail"];
            cell.selectionStyle = 0;
            if (indexPath.section == 0)
            {
                [cell.topLine setHidden:YES];
            }else
            {
                [cell.topLine setHidden:NO];
            }
            if ([rowDic[@"status"]isEqualToString:@"1"])
            {
                cell.bgimage.image = [UIImage imageNamed:@"BlueTongji"];
                cell.titleL.textColor = [UIColor whiteColor];
            }else if([rowDic[@"status"] isEqualToString:@"4"])
            {
                cell.bgimage.image = [UIImage imageNamed:@"RedTongji"];
                cell.titleL.textColor = [UIColor whiteColor];
            }else if ([rowDic[@"status"] isEqualToString:@"3"])
            {
                cell.bgimage.image = [UIImage imageNamed:@"graytongji.png"];
                cell.titleL.textColor = UIColors(0x333333);
            }else if ([rowDic[@"status"] isEqualToString:@"2"])
            {
                cell.bgimage.image = [UIImage imageNamed:@"OrangeTongji"];
                cell.titleL.textColor = [UIColor whiteColor];
            }
            cell.selectionStyle = 0;
            if (indexPath.section == 0) {
                [cell.topLine setHidden:YES];
            }else
            {
                [cell.topLine setHidden:NO];
            }

            if (indexPath.section == self.TeacherList.count-1)
            {
                if (dataArr.count == 1)
                {
                    [cell.bottomLine setHidden:YES];
                }else
                {
                    [cell.bottomLine setHidden:NO];
                }
            }else
            {
                [cell.bottomLine setHidden:NO];
            }

            return cell;
        }else
        {
            KeBiaoSecTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"KeBiaoSecTableViewCell" forIndexPath:indexPath];
            if ([rowDic[@"status"]isEqualToString:@"1"])
            {
                cell.bgImageV.image = [UIImage imageNamed:@"BlueTongji"];
                cell.titleL.textColor = [UIColor whiteColor];
            }else if([rowDic[@"status"] isEqualToString:@"4"])
            {
                cell.bgImageV.image = [UIImage imageNamed:@"RedTongji"];
                cell.titleL.textColor = [UIColor whiteColor];
            }else if ([rowDic[@"status"] isEqualToString:@"3"])
            {
                cell.bgImageV.image = [UIImage imageNamed:@"graytongji.png"];
                cell.titleL.textColor = UIColors(0x333333);
            }else if ([rowDic[@"status"] isEqualToString:@"2"])
            {
                cell.bgImageV.image = [UIImage imageNamed:@"OrangeTongji"];
                cell.titleL.textColor = [UIColor whiteColor];
            }        cell.titleL.text = rowDic[@"detail"];
            cell.titleL.text = rowDic[@"detail"];

            if (indexPath.section == self.TeacherList.count-1)
            {
                [cell.LineV setHidden:YES];
            }else
            {
                [cell.LineV setHidden:NO];
            }
            cell.selectionStyle = 0;
            return cell;
        }
    }else
    {
        TimeTableModel *model = self.listArr[indexPath.row];
        MainTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MainTableViewCell" forIndexPath:indexPath];
        cell.selectionStyle = 0;
        if (indexPath.row == 0) {
            cell.leftImage.image = [UIImage imageNamed:@"time_1"];
        }else
        {
            cell.leftImage.image = [UIImage imageNamed:@"time_2"];
        }
        if ([model.isleave isEqualToString:@"1"])
        {
            [cell.isHoilday setHidden:NO];
        }else
        {
            [cell.isHoilday setHidden:YES];
        }

        cell.titleLabel.text = model.coursename;
        cell.remarkLabel.text = model.detail;
        return cell;
    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([self.isTeacher isEqualToString:@"1"]) {
        return 60;
    }else
    {
        return 80;
    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return FLT_MIN;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return FLT_MIN;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    if ([self.isTeacher isEqualToString:@"1"])
    {
        NSDictionary *sectionDic = self.TeacherList[indexPath.section];
        NSArray *dataArr = sectionDic[@"data_v"];
        NSDictionary *rowDic = dataArr[indexPath.row];

        TeaacherCheckHolidayViewController *VC = [[TeaacherCheckHolidayViewController alloc]init];
        VC.ctaid = rowDic[@"aid"];
        [self.navigationController pushViewController:VC animated:YES];
    }else
    {

    }
}

//顶部没有弹簧效果 但是底部有
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    if (self.listV.contentOffset.y <= 0) {
        self.listV.bounces = NO;
    }else{
        self.listV.bounces = YES;
    }
}

#pragma mark --- 网络请求部分

/**
 轮播图的网络请求
 */
-(void)cycRequest
{

    [RequestManager RequstWithUrl:@"/index.php?g=App&m=Index&a=getIndexAd" parmDic:@{@"num":@"2"} requestType:RequestGET Success:^(id data)
    {
        self.cycleArr = data;

        [self ReloadCycImage:self.cycleArr];
        
    } error:^(NSError *error) {

    }];
}


/**
 不是老师列表的网络请求

 */
-(void)listRequest
{
    [RequestManager RequstWithUrl:@"/index.php?g=App&m=StudentIndex&a=courseTableindex" parmDic:@{} requestType:RequestGET Success:^(id data)
    {
        self.listArr = [TimeTableModel ModelConfigure:data];
        

        [self.listV reloadData];
    } error:^(NSError *error) {

    }];
}


#pragma 刷新数据的方法
-(void)ReloadCycImage:(NSMutableArray *)cycArr
{
    NSMutableArray *imageUrlArr = [NSMutableArray array];
    
    for (NSDictionary *cycDic in cycArr)
    {
        NSString *imageurl = [NSString stringWithFormat:@"%@%@",KUrl,cycDic[@"ad_file"]];
        [imageUrlArr addObject:imageurl];
    }
    
    self.cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, kScreenWidth, KscreenW*6/10) imageURLStringsGroup:imageUrlArr];
    self.cycleScrollView.delegate = self;
    [self.tabHeadV addSubview: self.cycleScrollView];
    [self.tabHeadV addSubview:self.drawerLeftBtn];
    [self.tabHeadV addSubview:self.MessageBtn];
    [self.tabHeadV addSubview:self.NumL];
    [self.tabHeadV addSubview:self.CatergyV];
    [self.CatergyV QieHuan:self.isTeacher];
    [self.tabHeadV addSubview:self.GongGaoV];
    [self.GongGaoV addSubview:self.notes];


    UIImageView *topImageV = [[UIImageView alloc]init];
    topImageV.frame = CGRectMake(5, 5, 20, 20);
    topImageV.image = [UIImage imageNamed:@"laba"];
    [self.GongGaoV addSubview:topImageV];

    UILabel *titleL = [[UILabel alloc]initWithFrame:CGRectMake(27, 5,80, 20)];
    titleL.font = [UIFont systemFontOfSize:14];
    titleL.textColor = UIColors(0x333333);
    titleL.text = @"校园公告:";
    [self.GongGaoV addSubview:titleL];


    UIView *bottomV = [[UIView alloc]init];
    bottomV .backgroundColor = [UIColor whiteColor];
    [self.tabHeadV addSubview:bottomV];
    [bottomV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.tabHeadV.mas_bottom);
        make.right.equalTo(self.tabHeadV.mas_right);
        make.left.equalTo(self.tabHeadV.mas_left);
        make.top.equalTo(self.GongGaoV.mas_bottom).offset(5);
    }];


    UILabel * bottomL = [[UILabel alloc]init];
    bottomL.text = @"最新课表";
    bottomL.font = [UIFont systemFontOfSize:14];
    [self.tabHeadV addSubview:bottomL];
    bottomL.textAlignment = 1;
//    bottomL.backgroundColor = [UIColor whiteColor];
    [bottomL mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.centerX.equalTo(self.tabHeadV.mas_centerX);
        make.bottom.equalTo(self.tabHeadV.mas_bottom);
        make.top.equalTo(self.GongGaoV.mas_bottom);
    }];

    UIImageView *line1 = [[UIImageView alloc]init];
    line1.image = [UIImage imageNamed:@"left_line"];
    [self.tabHeadV addSubview:line1];

    UIImageView *line2 = [[UIImageView alloc]init];
    line2.image = [UIImage imageNamed:@"right_line"];
    [self.tabHeadV addSubview:line2];

    [line1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(bottomL.mas_left).offset(-5);
        make.centerY.equalTo(bottomL.mas_centerY);
    }];

    [line2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bottomL.mas_right).offset(5);
        make.centerY.equalTo(bottomL.mas_centerY);
    }];
    [self getNumber];
//    [self.tabHeadV addSubview:self.more_timetable];
}

-(void)getNumber
{
    [RequestManager RequstWithUrl:@"/index.php?g=App&m=JpushLog&a=unreadLogsnum" parmDic:@{} requestType:RequestGET Success:^(id data)
    {
        self.NumL.text = data;
        if ([data isEqualToString:@"0"])
        {
            [self.NumL setHidden:YES];
        }else
        {
            [self.NumL setHidden:NO];
        }
    } error:^(NSError *error) {

    }];
}
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
{
    NSDictionary *dic = self.cycleArr[index];

    if ([dic[@"app_type"] isEqualToString:@"1"])
    {
        [self pushVc:dic[@"ad_link"]];
    }else
    {

    }
    NSLog(@"%ld",(long)index);
}

-(void)pushVc:(NSString *)ad_link
{
    if (![ad_link isEqualToString:@"#"])
    {
        MainWebViewController *VC = [[MainWebViewController alloc]init];
        VC.url = ad_link;
    }
}

#pragma mark ---界面按钮触发事件
/**
 打开/关闭抽屉的方法
 */
-(void)showLeftAct
{
    if (self.movetype == MOVETYPERIGHT)
    {
        [self ChangeFrameWithType:(MOVETYPELEFT)];
        
    }else 
    {
        [self ChangeFrameWithType:(MOVETYPERIGHT)];

    }
}


-(void)MessageAct
{
    MessageViewController *VC = [[MessageViewController alloc]init];
    [self.navigationController pushViewController:VC animated:YES];
}

-(void)ReloadDada:(NSString *)isTeacher
{
    if ([isTeacher isEqualToString:@"1"])
    {
        // 是老师
        [self TeacherRequest];
        self.isTeacher = @"1";
        [self.CatergyV QieHuan:self.isTeacher];
    }else
    {
       // 不是老师
        [self listRequest];
        self.isTeacher = @"2";
        [self.CatergyV QieHuan:self.isTeacher];
    }
}

-(void)TeacherRequest
{
    [RequestManager RequstWithUrl:@"/index.php?g=App&m=TeacherIndex&a=courseTableindex" parmDic:@{@"tid":[[NSUserDefaults standardUserDefaults]objectForKey:@"tid"]} requestType:RequestGET Success:^(id data)
    {
//        self.TeacherList = [MainTeacherModel ModelConfigure:data];
        self.TeacherList = data;

        [self.listV reloadData];
    } error:^(NSError *error)
    {

    }];
}


-(void)timetableOnclick
{
    if ([self.isTeacher isEqualToString:@"1"])
    {
        KeBiaoListViewController *VC = [[KeBiaoListViewController alloc]init];
        VC.cid = @"";
        [self.navigationController pushViewController:VC animated:YES];
    }else
    {
        [RequestManager RequstWithUrl:@"/index.php?g=App&m=StudentCourse&a=index" parmDic:@{} requestType:RequestGET Success:^(id data)
        {
            self.ClassAlertV.listArr = [SelectTeacherModel modelConfigure:data];
//            NSLog(@"%ld",self.ClassAlertV.listArr.count);            
            if (self.ClassAlertV.listArr.count == 1)
            {
                SelectTeacherModel *model = [self.ClassAlertV.listArr firstObject];
                TimetableViewController *timetableVC = [[TimetableViewController alloc]init];
                timetableVC.cid = model.cid;
                timetableVC.sid = model.sid;
                [self.navigationController pushViewController:timetableVC animated:YES];
            }else if (self.ClassAlertV.listArr.count == 0)
            {
                [HUD showText:@"学生未报班" AfterTime:1];
            }
            else
            {
                self.ClassAlertV.alpha = 1;
                [self.ClassAlertV.classV reloadData];
                __weak  typeof(self) myself = self;
                self.ClassAlertV.myselect = ^(NSString *selectid,NSString *sid)
                {
                    TimetableViewController *timetableVC = [[TimetableViewController alloc]init];
                    timetableVC.cid = selectid;
                    timetableVC.sid = sid;
                    [myself.navigationController pushViewController:timetableVC animated:YES];
                };
            }
        } error:^(NSError *error)
        {
        }];

    }
}

- (void)didSelectAtIndex:(NSInteger)index
{
    if (index == 0)
    {
        ChildViewController *VC = [[ChildViewController alloc]init];
        [self.navigationController pushViewController:VC animated:YES];
    }else if (index == 1)
    {
        LessonViewController *VC = [[LessonViewController alloc]init];
        [self.navigationController pushViewController:VC animated:YES];
    }else if (index == 2)
    {
        RecordViewController *VC = [[RecordViewController alloc]init];
        [self.navigationController pushViewController:VC animated:YES];
    }else if (index == 3)
    {
        LessonShareViewController *VC = [[LessonShareViewController alloc]init];
        [self.navigationController pushViewController:VC animated:YES];
    }else if (index == 4)
    {
        [self timetableOnclick];
    }else if (index == 5)
    {
        /*#import "MyClassViewController.h"
         #import "LessonTeacherViewController.h"
         #import "TeacherHoildayViewController.h"
         #import "TeacherFeedBackViewController.h"*/
        MyClassViewController * VC = [[MyClassViewController alloc]init];
        [self.navigationController pushViewController:VC animated:YES];
    }else if (index == 6)
    {
        LessonTeacherViewController * VC = [[LessonTeacherViewController alloc]init];
        [self.navigationController pushViewController:VC animated:YES];
    }else if (index == 7)
    {
        TeacherHoildayViewController * VC = [[TeacherHoildayViewController alloc]init];
        [self.navigationController pushViewController:VC animated:YES];
    }else if (index == 8)
    {
        TeacherFeedBackViewController * VC = [[TeacherFeedBackViewController alloc]init];
        [self.navigationController pushViewController:VC animated:YES];
    }else if (index == 9)
    {
        MineShouRuViewController *VC = [[MineShouRuViewController alloc]init];
        [self.navigationController pushViewController:VC animated:YES];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
